package com.itheima.health.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class DateUtils {
    public static String getLastDay(String s) {
        int year = Integer.parseInt(s.split("-")[0]);
        int month = Integer.parseInt(s.split("-")[1]);
        Calendar cal = Calendar.getInstance();

        cal.set(Calendar.YEAR,year);
        cal.set(Calendar.MONTH,month);
        cal.set(Calendar.DAY_OF_MONTH,1);
        cal.add(Calendar.DAY_OF_MONTH,-1);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        return simpleDateFormat.format(cal.getTime());
    }
}
